
# -*- encoding=utf-8 -*-
# 1、使用9号颜色识别和6号彩灯
# 2、触发红外对射1打开抬杆（舵机控制），触发红外对射2关闭抬杆

from froModuleDrivers.generalDeviceDriver import GeneralDeviceDriver
from froModuleDrivers.nioManager import NioManager
import time
from froModuleDrivers import LOGGER


LOGGER.set_lvl("debug")

driver = GeneralDeviceDriver("192.168.50.81", 4001)
manager = NioManager(driver)
manager.run()

driver.showVersion()
driver.setWaitTime(0.4) # 设置指令返回的等待时间为0.4秒
driver.setLanternSpecialMode()
while True:
    rgb565_value = driver.getColorDetectValueRGB565(9) # 获取rgb565
    if rgb565_value == -1:
        print(f"查询失败")
    else:
        print(f"RGB565的值是{rgb565_value}")
        driver.setLanternByLedColor(6,50, rgb565_value) # 控制彩灯

manager.shutdownGracefully() # 等待指令执行完毕后系统退出
